package mm.yy.mybaties;

import mm.yy.mybaties.bin.Classes;
import mm.yy.mybaties.bin.ConditionUser;
import mm.yy.mybaties.bin.User;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

/**
 * Created by Admin on 12/28 0028.
 */
public class UserTest {
    private String name="mm.yy.mybaties.userMapper";
    private String name1="mm.yy.mybaties.classMapper";

    @Test
    public void test(){
        String statement=name+".getUser";
        User user= MySessionFactory.getSession().selectOne(statement,5);
        System.out.println(user);
    }
    @Test
    public void test1(){
        String statement=name+".addUser";
        Map<String,String> map=new HashMap<>();
        map.put("name","韩庚");
        map.put("age","33");
        MySessionFactory.getSession().insert(statement,map);
    }
    @Test
    public void test2(){
        String statement=name+".deleteUser";
        MySessionFactory.getSession().delete(statement,18);
    }
    @Test
    public void test3(){
        String statement=name+".update";

        MySessionFactory.getSession().insert(statement,new User(5,"韩旭",7));
    }
    @Test
    public void test4(){
        String str ="2342asfghgyu56asdasda";
        TreeMap<Character,Integer> tm=new TreeMap<>();

    }
    @Test
    public void test5() {
        String statement = name1 + ".getClass";
        Classes c=MySessionFactory.getSession().selectOne(statement,1);
        System.out.println(c);
    }

    @Test
    public void test6() {
        String statement = name1 + ".getClass2";
        Classes c=MySessionFactory.getSession().selectOne(statement,1);
        System.out.println(c);
    }

    @Test
    public void test7() {
        String statement = name + ".getClass2";
        Classes c=MySessionFactory.getSession().selectOne(statement,1);
        System.out.println(c);
    }

    @Test
    public void test8() {
        String statement = name1 + ".getClass4";
        Classes c=MySessionFactory.getSession().selectOne(statement,1);
        System.out.println(c);
    }
    @Test
    public void test9() {
        String statement = name1 + ".getUser";
        String name="o";
        ConditionUser conditionUser=new ConditionUser("%"+name+"%",10,100);
       List<User> list=MySessionFactory.getSession().selectList(statement,conditionUser);
        System.out.println(list);
    }
    @Test
    public void test10(){
        String str="qqqWWWWW";
        String str1="QQQwwwww";
        UserTest u=new UserTest();
        boolean v=u.myCompare(str,str1);
        System.out.println(v);//true
    }
    public boolean myCompare(String c,String c2) {
//        char[] c = str.toCharArray();
//        char[] c2 = str1.toCharArray();
        if(c!=null && c2!=null){
            if (c.length() != c2.length()) {
                return false;
            } else {
                for (int i = 0; i < c.length(); i++) {
                    for (int j = 0; j < c2.length(); j++) {
                        String v1=c.toUpperCase();
                        String v2=c2.toUpperCase();
                        if(v1.equals(v2)){
                            return true;
                        }
                    }
                }
            }
        }
        return true;
    }
}